iBank - a Web Interface for the ATM
Central Server
In this example the iBank web front end interacts with the ATM Central
Server (atmcs), which further relays transaction requests to individual
banks. The interface design follows the object factory pattern.
This example demonstrates how to:
-
Design a web application using the Model/View/Controller framework
-
Implement a web application using the object factory pattern
-
Implement secure session management within the object factory pattern
This server must be used together with the ATM Central Server (interface
layer) and the Bank Server.
Together with web clients, they form a four-tier software system.
Source Files
-
atmcs.idl
IDL file for the interfaces SessionIF and SessionMgrIF in the atmcs
module. (IF stands for interface.) Also defined are exception
"AtmcsError", a cash card data structure CardInfo, and an account information
structure AccountInfo.
SessionMgrIF only has login and logout operations
exposed, though the implementation class may have conventional object management
operations.
-
Main.java
The main processor for web client requests. Main itself is a
servlet that runs within a servlet engine. In this example the Apache
JServ engine is used. However, since the servlet depends only on
the interfaces in the packages javax.servlet and javax.servlet.http, another
other compliant engine may be used.
This servlet acts as a client to the ATM Central Server. It init(
) method tries to connect to that Server when the servlet is first loaded
into the servlet engine. The service method processes all client
requests by extracting information from the HTTP query string or posted
data. Main.java is also an object factory in that it first verifies
the client's credential and then dynamically creates an "Application Bean"
to process specific requests. Thus all upfront security controls
are handled by this servlet.
-
Account.java
This class implements the interface ApplicationBean,
which defines only two operations: init and process. The method init
sets up some initial resources, including an HTML file template (payBill.htm).
The process method processes all requests related to an account (balance,
transfer, pay bill, etc.) Currently only balance and pay bill use
the HTML file template.
The template contains variables in the form ${...}, which are replaced
by their actual values before returning to the client. The HTML template
also contains some client-side javascript for simple error checking before
contacting the server.
-
Template.java
A simple utility that handles variable substitution in an HTML template
file. It makes use of regular expression to locate the variables.
Batch Files
-
build.bat
A batch file for building the client and server on Windows.
To build just the Java codes, simply type "build". To build also
the IDL codes, use "build idl".
For the latter case, it will first invoke the IDL compiler and then
compile the client source codes for atmcs.idl. A subdirectory named
"atmcs" will be created, which contains the CORBA stub codes and their
corresponding class files. A jar file atmcs-i.jar is generated afterwards.
-
setenv.bat
A batch file for setting some environment variables.
-
testmain.bat
A batch file for testing the Main class.
Running the Codes
This example was developed under VisiBroker (link)
and Apache web server with JServ servlet engine (link).
To run the servlet, you need to set up the JServ servlet engine correctly.
(Click here for details.)
After the set up is complete, make sure Apache is running with "net
start" (otherwise do "net start apache"). Then point your web browser
to http://localhost/ooda/ (note the
trailing slash!). Try the demo sevlet "Counter" to see if the servlet
engine is really working. Proceed only if it works. If not,
it means your configuration for JServ is problematic.
Before you can invoke the iBank application, you need to bring up both
the bank server and the atmcs-i server (we use only the interface layer
of atmcs to keep things simple). This involves three steps (since
this is a four-tier application, all tiers must be running):
-
cd to the studies/bank directory and do:
start runsrv
-
After the server is up, do:
client localhost test1.txt
This populates the bank server with some account informatoin.
-
cd to the studies/atmcs-i directory and do:
start runsrv
After the server is up, you may invoke ibank from http://localhost/ooda/.
To login, use "John" as username and "999" as password.